# coding=utf-8
import os


###### 【 3 】############################## 运行环境配置 ##########################################
class BaseConfig(object):
    APP_NAME = 'main'
    PROJECT = "app"
    PROJECT_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
    DEBUG = False

    LOG_FOLDER = os.path.join(PROJECT_ROOT, 'log')
    if not os.path.exists(LOG_FOLDER):
        os.mkdir(LOG_FOLDER)


class DefaultConfig(BaseConfig):
    DEBUG = False


def dev():
    os.environ["ODOOHOST"] = '192.168.1.89'

    os.environ["ODOOPORT"] = '19003'
    os.environ["ODOODBHOST"] = '192.168.1.89'
    os.environ["ODOODBPORT"] = '19005'
    os.environ["ODOODBNAME"] = 'devops'
    os.environ["ODOOADMINPWD"] = 'Hitachi123'
    os.environ["PG_USER"] = 'odoo'
    os.environ["PG_PASSWORD"] = 'odoo'

    os.environ["TEMP_PATH"] = '/Users/zzw/Downloads/temp'
    os.environ["VERSION"] = '1'
    os.environ["LOCAL_DOCKER_HOST"] = "tcp://192.168.1.89:2376"



    # MAIL_SERVER = 'smtp.exmail.qq.com'
    # MAIL_PORT = 465
    # MAIL_USE_TLS = False
    # MAIL_USE_SSL = True
    # MAIL_USERNAME = 'service@ming-china.cn'
    # MAIL_PASSWORD = 'Smt13579'


dev()


class DockerConfig(DefaultConfig):
    SECRET_KEY = os.urandom(24)
    ODOO_SERVER = 'http://%s:%s/' % (os.environ["ODOOHOST"], os.environ["ODOOPORT"])  # ODOO服务地址
    ODOO_DB_NAME = os.environ["ODOODBNAME"]  # ODOO服务地址
    ODOO_DB_ADMIN_PWD = os.environ["ODOOADMINPWD"]  # ODOO服务地址
    DB_URI = 'postgresql+psycopg2://%s:%s@%s:%s/%s' % (
        os.environ["PG_USER"], os.environ["PG_PASSWORD"], os.environ["ODOODBHOST"],
        os.environ["ODOODBPORT"], os.environ["ODOODBNAME"])  # ODOO服务地址
    use_wechat = False
    CACHE_CONFIG = {
        'CACHE_TYPE': 'simple',
    }

    VERSION = os.environ["VERSION"]
    TEMP_PATH = os.environ["TEMP_PATH"]
    LOCAL_DOCKER_HOST = os.environ["LOCAL_DOCKER_HOST"]
    MYSQL_HOST = os.environ.get("MYSQL_HOST", "192.168.1.90")
    MYSQL_PORT = os.environ.get("MYSQL_HOST", "3304")
    MYSQL_USR = os.environ.get("MYSQL_HOST", "root")
    MYSQL_PWD = os.environ.get("MYSQL_HOST", "redmine")
    MYSQL_DB = os.environ.get("MYSQL_HOST", "redmine")
